#pragma once
#include "UIlib.h"
#include "PreviewImageUI.h"
#include <opencv2/opencv.hpp>
#include "WuDong.h"

using namespace DuiLib;

//////////////////////////////////////////////////////////////////////////
///

class CMainWnd : public WindowImplBase
{
public:
	CMainWnd();
	~CMainWnd();

public:
	DuiLib::CDuiString GetSkinFile();
	LPCTSTR GetWindowClassName() const;
	UINT GetClassStyle() const;
	void InitWindow();
	void OnFinalMessage(HWND hWnd);

	CControlUI *CreateControl(LPCTSTR pstrClass);

	void Notify(TNotifyUI &msg);
	void OnClick(CControlUI *pControl);

	DUI_DECLARE_MESSAGE_MAP()

	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL &bHandled);

	LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);

	virtual LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL &bHandled) override;

	virtual LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);

private:
	void CalcSmallResult();

	void loadDictInfo(const std::wstring &dictName);

	void drawTestMat(const std::vector<cv::Rect> &rects);

	void reloadDictList();

private:
	CLabelUI *m_pLabelStatusWindow;

	CLabelUI *m_pLabelStatusSelect;

	CControlUI *m_pCtrlGetedColor;

	PreviewImageUI *m_pPreviewImage;

	PreviewImageUI *m_pPreviewSmallDemo;

	PreviewImageUI *m_pPreviewSmallResult;

	CSliderUI *m_pSliderTolerance;

	CEditUI *m_pToleranceEdit;

	CEditUI *m_pEditDictColor;

	CEditUI *m_pEditDictMode;

	CEditUI *m_pEditDictName;

	CEditUI *m_pEditFindPicName;
	CEditUI *m_pEditFindPicThreshold;
	CEditUI *m_pEditTestFindRect;

	CComboUI *m_pComboCurrDict;

	HWND m_selectedHwnd = 0;

	cv::Mat m_cutImg; // 截的图

	cv::Mat m_smallDemo;

	cv::Mat m_smallResult;

	WuDong wd;

	std::wstring m_savePath;
};
